package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum HandleProductWayEnum {
    /*
     * 操作出入库的方式 产品并发自定义注解使用
     * 1：新建时
     * 2：删除时
     */
    ADD(1, "add", "enum.assessType.name.add"),
    DELETE(2, "delete", "enum.assessType.name.delete"),
    PROCESS(3,"process","enum.assessType.name.process"),

    ;

    /** 枚举值 -- */
    private final int code;
    /** 枚举描述 --英文名称*/
    private final String	alias;
    /** 枚举信息--中文名称 */
    private final String    name;

    HandleProductWayEnum(int code, String alias, String name) {
        this.code = code;
        this.alias = alias;
        this.name = name;
    }

    /**
     * 获取全部枚举
     *
     * @return List<AssessTypeEnum>
     */
    public static List<HandleProductWayEnum> getAllEnum() {
        List<HandleProductWayEnum> list = new ArrayList<>();
        for (HandleProductWayEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    /**
     * 根据alias获取枚举
     * @return
     */
    public static HandleProductWayEnum getByCode(int code) {
        for (HandleProductWayEnum cache : values()) {
            if (code == cache.getCode()) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
